package com.xuhuan.demo.pattern.singleton.type7;

/**
 * @author huan.xu
 * @date 2021/10/2 23:08
 * @description 懒汉式(静态内部类)
 */
public class SingletonDemo7 {

  public static void main(String[] args) {
    for (int i = 0; i < 100; i++) {
      new Thread(() -> System.out.println(Singleton.getInstence())).start();
    }
  }
}

class Singleton {

  private Singleton() {
  }

  private static class SingletonInstance {

    private static final Singleton SINGLETON = new Singleton();
  }

  public static Singleton getInstence() {
    return SingletonInstance.SINGLETON;
  }
}
